<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
</head>
<body>
    <button onclick="getData()">发请求</button>
    <script>
        function p1 () {
            // 实例化
            let pObj = new Promise((resolve, reject) => {
                $.ajax({
                    url: 'http://localhost:3000/comment/music?id=186016&limit=1',
                    success: data => {
                        console.log('okk~');
                        resolve(data)
                    }
                })
            })
            return pObj
        }
        
        async function getData () {
            // let res = p1(); // 这一行是异步代码
            let res = await p1(); // 转换成了 同步代码,等待执行结果，给res赋值，然后继续向后执行
            // setTimeout(()=>{
            //     console.log(666);
            // }, 100)
            console.log(res);
        }
    </script>
</body>
</html>